package cc.htdf.gwc.datacompare.controller;

import cc.htdf.gwc.datacompare.domain.response.ResponseBody;
import cc.htdf.gwc.datacompare.domain.response.ResponseCode;
import cc.htdf.gwc.datacompare.service.DataCompareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import whisper.common.exception.format.ParseException;

import java.util.Map;

/**
 * Created by JT on 2017/10/12.
 */
@RestController
@RequestMapping("/data")
public class DataCompareController {


    @Autowired
    private DataCompareService dataCompareService;

    /**
     * 根据发布时间、预报次数、要素 查询值的平均差
     * @param modelRunDateTime：发布时效  "yyyyMMddHH"
     * @param validTimes：预报次数 例如： "96","360"
     */
    @GetMapping("/ChengDu")
    @CrossOrigin
    public ResponseBody fetchChengDuCompareData(@RequestParam("modelRunDateTime") String modelRunDateTime,
                                        @RequestParam("validTimes") String validTimes) throws ParseException {

        Map<Object, Map<String, Object>> data = dataCompareService.findCompareDatasByModelRunDateTimeAndTimes(modelRunDateTime, validTimes);
        ResponseBody body = new ResponseBody(ResponseCode.STATUS_SUCCESS, "获取数据成功！", data);
        return body;
    }
}
